import React, { Component } from 'react'
import './index.css'
export default function Header({addTodo}) {
    function addHandler(e){
        if(e.code !== 'Enter') return;
        addTodo(e.target.value)
        e.target.value = ''
    }
    return (
        <div className="todo-header">
            <input type="text" placeholder="请输入你的任务名称，按回车键确认" onKeyUp={addHandler}/>
        </div>
    )
}
